<!--  -->
<template>
  <div id="warpper" ref="scroll">
    <div class="conent">
      <slot></slot>
    </div>
  </div>
</template>

<script>
import BScroll from "better-scroll";
export default {
  components: {},
  props: {
    probeType: {
      type: Number,
      default() {
        return Number;
      },
    },
    pullUpLoad: {
      type: Boolean,
      default: false,
    },
  },
  data() {
    return {
      scroll: null,
    };
  },
  computed: {},
  watch: {},
  methods: {
    //返回顶部的封装方法
    scrollTo(x, y, time = 300) {
      this.scroll.scrollTo(x, y, time);
    },
    //刷新方法继续上拉加载更多
    finishPull() {
      this.scroll.finishPullUp();
    },
    //图片加载完成刷新页面
    refresh() {
      this.scroll.refresh();
    },
  },
  created() {},
  mounted() {
    this.scroll = new BScroll(this.$refs.scroll, {
      click: true,
      probeType: this.probeType,
      pullUpLoad: this.pullUpLoad,
    });
    //滚动位置记录 参数实时滚动位置
    this.scroll.on("scroll", (position) => {
      this.$emit("backScroll", position);
    });
    //上拉加载更多
    this.scroll.on("pullingUp", () => {
      this.$emit("pullingUp");
    });
  },
  updated() {},
};
</script>
<style lang="less" scoped>
//@import url();
</style>
